# 写一个函数 myrange 实现和 range 一样的功能， 但返回列表
# def myrange(start, stop=None, step=None):
# 	# return range(start, stop, step) 不能这样
#     if stop == None:  # 这是一个参数
#          return list(range(0, start))
# 	... 此处自己完成
#
# for x in myrange(4):
#     print(x)   # 0, 1, 2, 3
#
# for x in myrange(3, 6):
#     print(x)  # 3, 4, 5
# for x in myrange(1, 10, 2):
#     print(x)   # 1, 3, 5, 7, 9

def myrange(start, stop=None, step=None):
    if stop is None:  # 如火没有给出第二个参数
        stop = start
        start = 0
    if step is None:
        step = 1
    r_list = []
    # 向列表 r_list 内添加数据
    i = start   # i  代表生成的数
    if step > 0:
        while i < stop:
            r_list.append(i)
            i += step
    elif step < 0:
        while i > stop:
            r_list.append(i)
            i += step
    # 返回列表
    return r_list

for x in myrange(4):
    print(x)  # 0, 1, 2, 3

print('================================')

for x in myrange(3, 6):
    print(x)  # 3, 4, 5

print('================================')

for x in myrange(1, 10, 2):
    print(x)  # 1, 3, 5, 7, 9

print(myrange(5))  # [0, 1, 2, 3, 4]
print('=================================')
print(myrange(10, 0, -3))  # [10, 7, 4, 1]